#ifndef __xwt_dialog_h
  #define __xwt_dialog_h

#include "xwt_window.h"

XWT_BEGIN_NAMESPACE(xwt);

#ifdef WIN32
 typedef INT_PTR DLG_RET;
#endif

/** A base generic dialog window */
class Dialog : public Window {
	
public:
	// construct from resource id
	Dialog (int resourceId);

public:
	// operations
	bool IsModal () const {
		return m_flagModal;
	}
	DLG_RET ShowModal (Window *parent = NULL);
	void ShowModalLess (Window *parent = NULL);
	void CloseDialog (DLG_RET result = 0);
	void SetControlText (int id, const sys_tchar *text);
	void GetControlText (int id, sys_tchar *buffer, size_t max_len);
	void CenterDialog ();

	// event handlers...
protected:
	XWT_DECL_EVENT_HANDLER(Command) (int cmdid);
	XWT_DECL_EVENT_HANDLER(InitDialog) ();
	XWT_DECL_EVENT_HANDLER(OkButton) ();
	XWT_DECL_EVENT_HANDLER(CancelButton) ();

private:
	int m_resourceId;
	bool m_flagModal;
	Window *m_pParent;
};

XWT_END_NAMESPACE(xwt);

#endif /* __xwt_dialog_h */
